/*
 *  Copyright (C) 2009  Peter Kist & Jan Ripke
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <boost/test/unit_test.hpp>

#include <galaxy/Galaxy.h>
#include <galaxy/AppContext.h>
#include <mediator/InterMediator.h>
#include <mediator/Producer.h>
#include <logic/gamestate/Manager.h>
#include <logic/gamestate/StateFactory.h>

using namespace galaxy;
namespace state = galaxy::logic::gamestate;

BOOST_AUTO_TEST_SUITE( test_suite_logic )

//--------------------------------------------------------
//  SETUP INITIAL GAME STATE TEST
//--------------------------------------------------------

class TestProducer: public mediator::Producer {
public:
    int count;
    TestProducer() { count = 0; };
    virtual ~TestProducer() { };
    virtual bool handleQuery(const mediator::Query& query, 
        mediator::QueryResultPtr& result) { count++; return true; };
    virtual int category() { return mediator::CATEGORY_DEBUG; };
};

struct fixture_initial_state_test {
    Galaxy    * galaxy;
    AppContext& appContext;

    TestProducer      producer1;

    state::ManagerPtr  m_Manager;
    state::StatePtr    m_MainState;

    fixture_initial_state_test() : appContext(AppContext::singleton()) {
        galaxy  = new Galaxy();
        appContext.game = galaxy;

        galaxy->initialize();
        galaxy->initializeMediator();

        mediator::InterMediator::registerProducer(producer1);
    };
    ~fixture_initial_state_test() { };
};

BOOST_FIXTURE_TEST_CASE(InitialStateTest, fixture_initial_state_test) {
    m_MainState = state::StateFactory::createState(logic::State::c_MainMenu);
    BOOST_CHECK (m_MainState);

    //galaxy->getStateManager()->setupInitialState(logic::State::c_MainMenu);
    //BOOST_CHECK (producer1.count == 1);
}


//
// END TESTS
//

BOOST_AUTO_TEST_SUITE_END()